"""empty message

Revision ID: 413ebe1ef0d5
Revises: f53af2d39508
Create Date: 2025-08-17 18:36:26.951311

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = '413ebe1ef0d5'
down_revision: Union[str, None] = 'f53af2d39508'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('evaluation_items',
    sa.Column('id', sa.String(length=24), nullable=False),
    sa.Column('evaluation_id', sa.String(length=24), nullable=False),
    sa.Column('question_id', sa.String(length=24), nullable=True),
    sa.Column('status', sa.String(length=50), nullable=False),
    sa.Column('question_text', sa.Text(), nullable=False),
    sa.Column('ground_truth', sa.Text(), nullable=False),
    sa.Column('rag_answer', sa.Text(), nullable=True),
    sa.Column('rag_answer_details', sa.JSON(), nullable=True),
    sa.Column('llm_judge_score', sa.Integer(), nullable=True),
    sa.Column('llm_judge_reasoning', sa.Text(), nullable=True),
    sa.Column('gmt_created', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_updated', sa.DateTime(timezone=True), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_evaluation_items_evaluation_id', 'evaluation_items', ['evaluation_id'], unique=False)
    op.create_index(op.f('ix_evaluation_items_status'), 'evaluation_items', ['status'], unique=False)
    op.create_table('evaluations',
    sa.Column('id', sa.String(length=24), nullable=False),
    sa.Column('user_id', sa.String(length=24), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('collection_id', sa.String(length=24), nullable=False),
    sa.Column('question_set_id', sa.String(length=24), nullable=False),
    sa.Column('agent_llm_config', sa.JSON(), nullable=False),
    sa.Column('judge_llm_config', sa.JSON(), nullable=False),
    sa.Column('status', sa.String(length=50), nullable=False),
    sa.Column('error_message', sa.Text(), nullable=True),
    sa.Column('total_questions', sa.Integer(), nullable=False),
    sa.Column('completed_questions', sa.Integer(), nullable=False),
    sa.Column('average_score', sa.Numeric(precision=3, scale=2), nullable=True),
    sa.Column('gmt_created', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_updated', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_deleted', sa.DateTime(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_evaluations_status', 'evaluations', ['status'], unique=False)
    op.create_index('idx_evaluations_user_id', 'evaluations', ['user_id'], unique=False)
    op.create_table('question_sets',
    sa.Column('id', sa.String(length=24), nullable=False),
    sa.Column('user_id', sa.String(length=24), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('gmt_created', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_updated', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_deleted', sa.DateTime(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_question_sets_user_id', 'question_sets', ['user_id'], unique=False)
    op.create_table('questions',
    sa.Column('id', sa.String(length=24), nullable=False),
    sa.Column('question_set_id', sa.String(length=24), nullable=False),
    sa.Column('question_type', sa.String(length=50), nullable=True),
    sa.Column('question_text', sa.Text(), nullable=False),
    sa.Column('ground_truth', sa.Text(), nullable=False),
    sa.Column('gmt_created', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_updated', sa.DateTime(timezone=True), nullable=False),
    sa.Column('gmt_deleted', sa.DateTime(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('idx_questions_question_set_id', 'questions', ['question_set_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('idx_questions_question_set_id', table_name='questions')
    op.drop_table('questions')
    op.drop_index('idx_question_sets_user_id', table_name='question_sets')
    op.drop_table('question_sets')
    op.drop_index('idx_evaluations_user_id', table_name='evaluations')
    op.drop_index('idx_evaluations_status', table_name='evaluations')
    op.drop_table('evaluations')
    op.drop_index(op.f('ix_evaluation_items_status'), table_name='evaluation_items')
    op.drop_index('idx_evaluation_items_evaluation_id', table_name='evaluation_items')
    op.drop_table('evaluation_items')
    # ### end Alembic commands ###
